package com.newlink.building.userinfo.adapter

import android.widget.CheckBox
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.newlink.building.userinfo.R
import com.newlink.building.userinfo.bean.Module_UserInfo_CallSettingCallPreferenceDialogBean

/**
 * @author wangyang
 * @date 2022/10/18
 * @description 我的——通话设置——呼叫偏好页面的dialog的Adapter
 */
class Module_UserInfo_CallSettingCallPreferenceDialogAdapter(data: MutableList<Module_UserInfo_CallSettingCallPreferenceDialogBean>) :
    BaseQuickAdapter<Module_UserInfo_CallSettingCallPreferenceDialogBean, BaseViewHolder>(
        R.layout.item_call_setting_call_preference_dialog,
        data
    ) {

    init {
        addChildClickViewIds(R.id.area_container)
    }

    override fun convert(holder: BaseViewHolder, item: Module_UserInfo_CallSettingCallPreferenceDialogBean) {
        if (item.name == context.getString(R.string.call_setting_call_preferences_state)
            || item.name == context.getString(R.string.call_setting_call_preferences_ring_time)
        ) {
            holder.setText(R.id.tv_content, item.content)
        } else {
            holder.setText(R.id.tv_content, item.name)
        }
        val checkBox = holder.getView<CheckBox>(R.id.cb_select)
        checkBox.isChecked = item.isChecked

        if (item.isChecked) {
            holder.setTextColor(R.id.tv_content, context.getColor(R.color.default_red))
        } else {
            holder.setTextColor(R.id.tv_content, context.getColor(R.color.default_text))
        }
    }
}